﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;
using Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// Default implementation for ordered columns when super columns are used
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="SN"></typeparam>
    /// <typeparam name="N"></typeparam>
    /// <typeparam name="V"></typeparam>
    public class OrderedSuperRowsImpl<K, SN, N, V> : SuperRowsImpl<K, SN, N, V>, OrderedSuperRows<K, SN, N, V>
    {
        public OrderedSuperRowsImpl(Dictionary<K, List<SuperColumn>> thriftRet, Serializer<K> keySerializer,
            Serializer<SN> sNameSerializer, Serializer<N> nameSerializer,
            Serializer<V> valueSerializer) :
            base(thriftRet, keySerializer, sNameSerializer, nameSerializer, valueSerializer)
        {
            List = new List<SuperRow<K, SN, N, V>>(Rows.Values);
        }
        public List<SuperRow<K, SN, N, V>> List
        {
            get;
            set;
        }
        public List<SuperRow<K, SN, N, V>> GetList()
        {
            return List;
        }
        public new IEnumerator<SuperRow<K, SN, N, V>> GetEnumerator()
        {
            return List.GetEnumerator();
        }
    }
}
